package cre.sample.test.ds.order;

/**
 * Created by CreGu on 2016/5/25.
 */
public class ArrayInsert extends ArrayAbstract{


    public ArrayInsert(int size) {
        super(size);
    }

    public void insertSort() {
//        out是那个选中的元素
        for (int out = 1; out < elements; out++) {
            long tmp = arr[out];//选中的元素放临时变量
            int in = out;

            while (in > 0 && arr[in - 1] > tmp) {
                arr[in] = arr[in - 1];
                in--;
            }
            arr[in] = tmp;
        }

    }
}
